package com.milk.controller.admin;

import com.milk.entity.SignInReward;
import com.milk.result.Result;
import com.milk.service.ISignInRewardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/sign")
public class SignInRewardController {
    @Autowired
    private ISignInRewardService signInRewardService;

    /**
     * 查询所有签到奖励表数据
     * @return
     */
    @GetMapping
    public Result<List<SignInReward>> selectAll(){
        List<SignInReward> list = signInRewardService.selectAll();
        return Result.success(list);
    }

    /**
     * 更新签到奖励表
     * @param signInReward
     * @return
     */
    @PostMapping("/update")
    public Result update(@RequestBody SignInReward signInReward){
        signInRewardService.updateById(signInReward);
        return Result.success();
    }

    /**
     * 新增签到奖励表
     * @param signInReward
     * @return
     */
    @PostMapping("/insert")
    public Result isnert(@RequestBody SignInReward signInReward){
        signInRewardService.save(signInReward);
        return Result.success();
    }

    /**
     * 删除签到奖励表
     * @param ids
     * @return
     */
    @DeleteMapping("/{ids}")
    public Result deleteByIds(@PathVariable List<Long> ids){
        signInRewardService.removeByIds(ids);
        return Result.success();
    }
}
